package com.google.gwt.sample.stockwatcher.client;

import com.google.gwt.user.client.rpc.impl.RemoteServiceProxy;
import com.google.gwt.user.client.rpc.impl.ClientSerializationStreamWriter;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.ResponseReader;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.core.client.impl.Impl;
import com.google.gwt.user.client.rpc.impl.RpcStatsContext;

public class ItemSuggestService_Proxy extends RemoteServiceProxy implements com.google.gwt.sample.stockwatcher.client.ItemSuggestServiceAsync {
  private static final String REMOTE_SERVICE_INTERFACE_NAME = "com.google.gwt.sample.stockwatcher.client.ItemSuggestService";
  private static final String SERIALIZATION_POLICY ="52F1EDED756B0E081235ED4685681C42";
  private static final com.google.gwt.sample.stockwatcher.client.ItemSuggestService_TypeSerializer SERIALIZER = new com.google.gwt.sample.stockwatcher.client.ItemSuggestService_TypeSerializer();
  
  public ItemSuggestService_Proxy() {
    super(GWT.getModuleBaseURL(),
      null, 
      SERIALIZATION_POLICY, 
      SERIALIZER);
  }
  
  public void getSuggestions(com.google.gwt.user.client.ui.SuggestOracle.Request req, com.google.gwt.user.client.rpc.AsyncCallback callback) {
    RpcStatsContext statsContext = new RpcStatsContext();
    boolean toss = statsContext.isStatsAvailable() && statsContext.stats(statsContext.timeStat("ItemSuggestService_Proxy.getSuggestions", "begin"));
    SerializationStreamWriter streamWriter = createStreamWriter();
    // createStreamWriter() prepared the stream
    try {
      streamWriter.writeString(REMOTE_SERVICE_INTERFACE_NAME);
      streamWriter.writeString("getSuggestions");
      streamWriter.writeInt(1);
      streamWriter.writeString("com.google.gwt.user.client.ui.SuggestOracle$Request/3707347745");
      streamWriter.writeObject(req);
      String payload = streamWriter.toString();
      toss = statsContext.isStatsAvailable() && statsContext.stats(statsContext.timeStat("ItemSuggestService_Proxy.getSuggestions",  "requestSerialized"));
      doInvoke(ResponseReader.OBJECT, "ItemSuggestService_Proxy.getSuggestions", statsContext, payload, callback);
    } catch (SerializationException ex) {
      callback.onFailure(ex);
    }
  }
}
